package com.kefu.call.vo;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.kefu.call.model.CallGateway;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractSearchVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;

/**
 * @author CodeGenerator
 * @date 2022/07/24
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "网关表")
public class CallGatewaySearchVo extends AbstractSearchVo {

    @ApiModelProperty(value = "名称")
    private String memo;
    @ApiModelProperty(value = "注册用户名")
    private String username;
    @ApiModelProperty(value = "线路号码")
    private String gwNumber;


    @Override
    public LambdaQueryWrapper<CallGateway> lambdaQuery() {
        LambdaQueryWrapper<CallGateway> wrapper = Wrappers.<CallGateway>lambdaQuery();
        wrapper.like(StringUtils.isNotBlank(memo), CallGateway::getMemo, memo);//名称
        wrapper.like(StringUtils.isNotBlank(username), CallGateway::getUsername, username);//注册用户名
        wrapper.like(StringUtils.isNotBlank(gwNumber), CallGateway::getUsername, gwNumber);//注册用户名
        wrapper.eq(CallGateway::getCompany, KefuContext.getTid());//公司ID
        wrapper.isNull(CallGateway::getAgentgw);

        return wrapper;
    }
}